/**
 * 
 */
package org.dragonfire.irc.server.routing;

import org.dragonfire.irc.server.ServerConnection;

/**
 * @author Darth Android
 * @date Oct 30, 2007
 */
public class Route implements Comparable<Route> {

	private String name;
	private ServerConnection connection;
	private int distance;

	/**
	 * @param name
	 * @param connection
	 * @param distance
	 */
	public Route(String name, ServerConnection connection, int distance) {
		super();
		this.name = name;
		this.connection = connection;
		this.distance = distance;
	}

	/**
	 * @return the distance
	 */
	public int getDistance() {
		return distance;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return the connection
	 */
	public ServerConnection getConnection() {
		return connection;
	}

	public int compareTo(Route o) {
		if (getName().equals(o.getName()))
			if (getDistance() == o.getDistance())
				return getConnection().compareTo(o.getConnection());
			else
				return getDistance() - o.getDistance();
		return getName().compareToIgnoreCase(o.getName());

	}
}
